#pragma once
#include<string>
#include<vector>

class Util
{
public:
     static std::string IntToStr(int val)
     {
        // 特殊处理
        if(val == 0)
        return "0";

        std::string str;
        while(val)
        {
            str += (val %10) + '0';
            val /= 10;
        }
       int left = 0;
       int right = str.size() - 1;
       while(left < right)
       std::swap(str[left++],str[right--]);
       return str;
     }

     static int StrToInt(const std::string& str)
     {
        int ret = 0;
        for(auto e :str)
        {
            ret = ret * 10 + (e - '0'); 
        }
        return ret;
     }

     static void StringSplit(const std::string& str, const std::string& sep, std::vector<std::string>* result)
     {
        size_t left = 0;
        size_t right = 0;
        while(right<str.size())
        {
            right = str.find(sep,left);

            if(right == std::string::npos)
            {
                result->push_back(str.substr(left));
                break;
            }

            result->push_back(str.substr(left,right-left));
            left = right +sep.size();
        } 
     }
};
